import http from '@/utils/http'

const BASE_URL = '/sport/team'

export interface TeamResp {
  number: string
  name: string
  createTime: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface TeamDetailResp {
  id: string
  athleteId: string
  number: string
  name: string
  createTime: string
  updateTime: string
  createUser: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface TeamQuery {
  number: string
  name: string
  createTime: string
  updateTime: string
  sort: Array<string>
}
export interface TeamPageQuery extends TeamQuery, PageQuery {}

/** @desc 查询团体 列表 */
export function listTeam(query: TeamPageQuery) {
  return http.get<PageRes<TeamResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询团体 详情 */
export function getTeam(id: string) {
  return http.get<TeamDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增团体  */
export function addTeam(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改团体  */
export function updateTeam(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除团体  */
export function deleteTeam(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出团体  */
export function exportTeam(query: TeamQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
